#include <cstdio>
#include <cmath>
#define M 1000000007
typedef long long LL;
LL g(LL x)
{
    if ( x == 1 )
        return 1;
    if ( x == 0 )
        return 0;
    else
        return 3*g(x-1)+g(x-2);
}

int main()
{
    //freopen("in.txt","r",stdin);
    LL x;
    /*for (int i=1;i<30;i++)
    {
        printf("%I64d\n",g(i));
    }*/
    scanf("%I64d",&x);
    printf("%I64d\n",g(x)%M);
    printf("%I64d\n",g(g(x)%M));
        printf("%I64d\n",g(g(g(x)%M)%M));

   // printf("%I64d\n",g(x));

}
